package com.ogawa.a7517.fragment;

import android.view.View;
import android.widget.TextView;

import com.example.reslib.Constants;
import com.example.reslib.utils.PreferenceWrapper;
import com.ogawa.a7517.Constant;
import com.ogawa.a7517.R;

import java.util.Locale;

public class SettingFragment extends BaseFragment implements View.OnClickListener {
    @Override
    public int getLayoutId() {
        return R.layout.fragment_setting;
    }

    @Override
    public void initView(View view) {
        view.findViewById(R.id.iv_bg_upper).setOnClickListener(this);
        view.findViewById(R.id.iv_bg_down).setOnClickListener(this);
        view.findViewById(R.id.view_long_click).setOnLongClickListener(view1 -> {
            activity7517.startToFragmentAddToStack(new FactoryPswFragment());
            return true;
        });
        TextView tvLanguage = view.findViewById(R.id.tv_language);
        String language = new PreferenceWrapper().getStringValue(Constant.LANGUAGE, Constants.ZH);
        if (Constants.EN.equals(language)) {
            tvLanguage.setText(R.string.english);
        } else if (Constants.ZH.equals(language)) {
            tvLanguage.setText(R.string.simple_chinese);
        } else if (Constants.HK.equals(language)) {
            tvLanguage.setText(R.string.cantonese);
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        setTitle(getString(R.string.setting));
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.iv_bg_upper) {
            activity7517.startToFragmentAddToStack(new LanguageFragment());
        } else if (view.getId() == R.id.iv_bg_down) {
            activity7517.startToFragmentAddToStack(new WifiNetFragment());
        }
    }
}
